import { http } from '@/utils/http'
import { useMemberStore } from '@/store'

const baseURL = '/core/login'

const LoginApi = {
  login: (data: any) => {
    return http({
      url: `${baseURL}/loginSysUser`,
      method: 'POST',
      data: {
        ...data,
      },
    }).then((res) => {
      useMemberStore().setProfile(res.data)
    })
  },
  logOut: () => {
    return http({
      url: `${baseURL}/logoutUser`,
      method: 'GET',
    }).then((res) => {
      useMemberStore().clearProfile()
    })
  },
}

export default LoginApi
